import { S } from '../../s';
import { IPSAppDEField } from '../../app/dataentity/ipsapp-defield';
import { IPSDEGridDataItem } from './ipsdegrid-data-item';
import { PSDataItemImpl } from '../../data/psdata-item-impl';

export class PSDEGridDataItemImpl
  extends PSDataItemImpl
  implements IPSDEGridDataItem
{
  get format(): string {
    return this.M.format;
  }

  protected psappdefield: IPSAppDEField;
  getPSAppDEField(): IPSAppDEField | null {
    return (
      this.psappdefield ||
      (this.psappdefield = this.fillObjectModel(
        S._1,
        this.M.getPSAppDEField,
        S._2e4,
      ) as IPSAppDEField)
    );
  }

  get scriptCode(): string {
    return this.M.scriptCode;
  }

  get valueType():
    | 'SIMPLE'
    | 'SIMPLES'
    | 'OBJECT'
    | 'OBJECTS'
    | 'USER'
    | 'USER2' {
    return this.M.valueType || 'SIMPLE';
  }

  get customCode(): boolean {
    return this.M.customCode != null ? this.M.customCode : false;
  }

  get dataAccessAction(): boolean {
    return this.M.dataAccessAction != null ? this.M.dataAccessAction : false;
  }
  get cls(): string {
    return 'PSDEGridDataItemImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._28f) return true;
    return super.instanceof(cls);
  }
}
